﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using schedulelist.ORM.dao.interfaces;
using schedulelist.ORM.domain;
using NHibernate;
namespace schedulelist.ORM.dao.classes
{
    class CustomerDAO : GenericDAO<Customer>, ICustomerDAO
    {
        public CustomerDAO(ISession session) : base(session) { }
        public Customer getCustomerByName(
        string name)
        {
            var list = session.CreateSQLQuery(
            "SELECT customer.* FROM customer" +
            " WHERE customer.name='" + name + "'")
            .AddEntity("Customer", typeof(Customer))
            .List<Customer>();
            Customer cust = list[0];
            return cust;
        }

        public Customer getCustomerById(
        int id)
        {
            var list = session.CreateSQLQuery(
            "SELECT customer.* FROM customer" +
            " WHERE customer.Id='" + id + "'")
            .AddEntity("Customer", typeof(Customer))
            .List<Customer>();
            Customer cust = list[0];
            return cust;
        }
    }
}
